<?php
namespace App\Services;
use Exception;

class DeviceService
{
    public static function systemLists($system = "N")
    {
        $systems = ["其他","安卓","Iphone","iPad","Windows","Mac"];
        if ($system == "N") return $systems;
        try {
            return $systems[$system];
        } catch (Exception $e) {
            return "-";
        }
    }

    public static function deviceLists($device = 0)
    {
        $devices = ["其他","华为","Vivo","小米","OPPO","三星","苹果"];
        try {
            return $devices[$device];
        } catch (Exception $e) {
            return "-";
        }
    }

    public static function browserNames($browser = 0)
    {
        $browsers = ["","微信浏览器","电脑QQ浏览器","Vivo浏览器","Oppo浏览器","华为浏览器","小米浏览器","QQ浏览器","支付宝浏览器","百度APP","微博浏览器","爱奇艺浏览器","小米浏览器","喜马拉雅","钉钉","UC浏览器","三星浏览器","诺基亚浏览器","欧朋","火狐","知乎","飞书","Iphone","Ipad","苹果电脑","其他浏览器","抖音APP"];
        try {
            return $browsers[$browser];
        } catch (Exception $e) {
            return "-";
        }
    }

    public static function userAgentBrowser($browser)
    {
        $browsers = ["MicroMessenger"=>"微信浏览器","QQBrowser"=>"电脑QQ浏览器","VivoBrowser"=>"Vivo浏览器","HeyTapBrowser"=>"Oppo浏览器","HuaweiBrowser"=>"华为浏览器","MiuiBrowser"=>"小米浏览器","MQQBrowser"=>"QQ浏览器","AlipayClient"=>"支付宝浏览器","baiduboxapp"=>"百度APP","Weibo"=>"微博浏览器","iqiyi"=>"爱奇艺浏览器","aweme"=>"小米浏览器","kdtUnion_iting"=>"喜马拉雅","DingTalk"=>"钉钉","UCBrowser"=>"UC浏览器","SamsungBrowser"=>"三星浏览器","NokiaBrowser"=>"诺基亚浏览器","Opera"=>"欧朋","Firefox"=>"火狐","Zhihu"=>"知乎","Feishu"=>"飞书","iPhone"=>"苹果浏览器","iPad"=>"苹果浏览器","Macintosh"=>"苹果浏览器","Other"=>"其他"];
        try {
            return $browsers[$browser];
        } catch (Exception $e) {
            return "其他浏览器";
        }
    }

    public static function browserNamesLists($browser = "")
    {
        $browsers = ["","微信浏览器","电脑QQ浏览器","Vivo浏览器","Oppo浏览器","华为浏览器","小米浏览器","QQ浏览器","支付宝浏览器","百度APP","微博浏览器","爱奇艺浏览器","小米浏览器","喜马拉雅","钉钉","UC浏览器","三星浏览器","诺基亚浏览器","欧朋","火狐","知乎","飞书","Iphone","Ipad","苹果电脑","其他浏览器","抖音APP"];        
        return $browsers;
    }

    public static function deviceNames($device = "")
    {
        $devices = ["其他","华为","Vivo","小米","OPPO","三星","苹果"];
        return $devices;
    }

    public static function getSystem($system)
    {
        // 临时使用
        // $systems = ["其他","安卓","Iphone","iPad","Windows","Mac"];
        if ($system == "android" || $system == "Android") {
            return 1;
        } elseif ($system == "iPhone" || $system == "ios") {
            return 2;
        } elseif ($system == "Windows") {
            return 4;
        } elseif ($system == "Mac") {
            return 5;
        } else {
            return 0;
        }
    }

    public static function getDevices($device)
    {
        // 临时使用
        // $devices = ["其他","华为","Vivo","小米","OPPO","三星","苹果"];
        if ($device == "Huawei" || $device == "HONOR") {
            return 1;
        } elseif ($device == "Vivo" || $device == "iQOO") {
            return 2;
        } elseif ($device == "Xiaomi" || $device == "Redmi") {
            return 3;
        } elseif ($device == "OPPO" || $device == "Realme" || $device == "OnePlus") {
            return 4;
        } elseif ($device == "Samsung") {
            return 5;
        } elseif ($device == "Apple") {
            return 6;
        } else {
            return 0;
        }
    }
}
